package cn.stronglink.asset.module.basicdata.assetTypeAttr.service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.toolkit.IdWorker;
import cn.stronglink.asset.model.AssetTypeAttr;
import cn.stronglink.asset.module.basicdata.assetTypeAttr.mapper.AssetTypeAttrMapper;
import cn.stronglink.suite.core.util.WebUtil;

@Service
@Transactional(rollbackFor=Exception.class) 
public class AssetTypeAttrService {

	@Autowired
	private AssetTypeAttrMapper assetTypeAttrMapper;

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public List<AssetTypeAttr> queryAssetTypeAttr(Map<String, Object>  params) {		
		return assetTypeAttrMapper.queryAssetTypeAttr(params);	
	}
	
	public void removeAssetTypeAttr(Long id){
		assetTypeAttrMapper.removeAssetTypeAttr(id);	
	}	

	public void insertAssetTypeAttr(AssetTypeAttr assetTypeAttr) {
		if (assetTypeAttr.getId() == null) {
			assetTypeAttr.setId(IdWorker.getId());
			assetTypeAttr.setCreateBy(WebUtil.getCurrentUser());
			assetTypeAttr.setCreateTime(new Date());
			assetTypeAttrMapper.insertAssetTypeAttr(assetTypeAttr);		
		}else{
			assetTypeAttr.setUpdateBy(WebUtil.getCurrentUser());
			assetTypeAttr.setUpdateTime(new Date());
			assetTypeAttrMapper.updateAssetTypeAttr(assetTypeAttr);
		}	
		
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public AssetTypeAttr qryById(Long id) {
		return assetTypeAttrMapper.qryById(id);	
	}


}
